package com.jiyun.purse.controller;

import com.jiyun.pojo.purse.Purse;
import com.jiyun.purse.service.PurseService;
import com.jiyun.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/purse")
public class PurseController {
    @Autowired
    private PurseService purseService;

    @GetMapping("/findPurse")
    public Result findPurse(Integer userId){
        return Result.ok(purseService.findPurse(userId));
    }

    @GetMapping("/findPurseById/{id}")
    public Result findPurseById(@PathVariable Integer id){
        return Result.ok(purseService.findPurseById(id));
    }

    @PostMapping("/deletePurse/{id}")
    public Result deletePurse(@PathVariable Integer id){
        return Result.ok(purseService.deletePurse(id));
    }

    @PostMapping("/addCard")
    public Result addCard(@RequestBody Purse purse){
        return Result.ok(purseService.addCard(purse));
    }
//    修改状态
    @GetMapping("/updatePP/{id}")
    public Result updatePP(@PathVariable Integer id){
        return Result.ok(purseService.updatePP(id));
    }

    @GetMapping("/updatePS/{id}")
    public Result updatePS(@PathVariable Integer id){
        return Result.ok(purseService.updatePS(id));
    }

    @GetMapping("/updatePF/{id}")
    public Result updatePF(@PathVariable Integer id){
        return Result.ok(purseService.updatePF(id));
    }
    @GetMapping("/updatePF1/{id}")
    public Result updatePF1(@PathVariable Integer id){
        return Result.ok(purseService.updatePF1(id));
    }
}
